#ifndef FILTER_OPERATION_NODE_H
#define FILTER_OPERATION_NODE_H

#include "OperationNode.h"
#include "SharedArray.h"
#include "Column.h"

class ExpressionNode;

// Filters incoming data. It takes ownership of source and expression.
class FilterOperationNode: public OperationNode {
	public:
		// Takes source of data and filtering expression (it's root).
		// Takes ownership of the source.
		FilterOperationNode(OperationNode* source, ExpressionNode* expression);
		~FilterOperationNode();

		// Pulls data from source until it has enough data, filters it and
		// returns the result. Remaining pulled data is buffered for next pull.
		virtual SharedArray<Column> pull();

	private:
		OperationNode* _source;
		ExpressionNode* _expression;
		SharedArray<Column> _remainder;
		int _current;
};

#endif
